<?php

/**
 * This is the model class for table "tbl_bidjob".
 *
 * The followings are the available columns in table 'tbl_bidjob':
 * @property integer $id
 * @property integer $job_id
 * @property integer $user_id
 * @property integer $money
 * @property string $desc
 * @property integer $status
 * @property integer $timeduration
 * @property string $checkPoint
 * @property string $timepost
 * @property string $timecontract
 *
 * The followings are the available model relations:
 * @property Job $job
 * @property Users $user
 */
class Bidjob extends CActiveRecord
{
    /**
     * Returns the static model of the specified AR class.
     * @param string $className active record class name.
     * @return Bidjob the static model class
     */
    public static function model($className=__CLASS__)
    {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName()
    {
        return 'tbl_bidjob';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules()
    {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('job_id, user_id, money, desc, status, timeduration, checkPoint', 'required'),
            array('job_id, user_id, money, status, timeduration', 'numerical', 'integerOnly'=>true),
            array('desc, checkPoint', 'length', 'max'=>100),
            array('timecontract', 'safe'),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('id, job_id, user_id, money, desc, status, timeduration, checkPoint, timepost, timecontract', 'safe', 'on'=>'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations()
    {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
            'job' => array(self::BELONGS_TO, 'Job', 'job_id'),
            'user' => array(self::BELONGS_TO, 'Users', 'user_id'),
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'id' => 'ID',
            'job_id' => 'Job',
            'user_id' => 'User',
            'money' => 'Money',
            'desc' => 'Desc',
            'status' => 'Status',
            'timeduration' => 'Timeduration',
            'checkPoint' => 'Check Point',
            'timepost' => 'Timepost',
            'timecontract' => 'Timecontract',
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search()
    {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria=new CDbCriteria;

        $criteria->compare('id',$this->id);
        $criteria->compare('job_id',$this->job_id);
        $criteria->compare('user_id',$this->user_id);
        $criteria->compare('money',$this->money);
        $criteria->compare('desc',$this->desc,true);
        $criteria->compare('status',$this->status);
        $criteria->compare('timeduration',$this->timeduration);
        $criteria->compare('checkPoint',$this->checkPoint,true);
        $criteria->compare('timepost',$this->timepost,true);
        $criteria->compare('timecontract',$this->timecontract,true);

        return new CActiveDataProvider($this, array(
            'criteria'=>$criteria,
        ));
    }
}